
<link href="<{$res_url}>/css/wap/public.css" rel="stylesheet" type="text/css">
<link href="<{$res_url}>/css/wap/home.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<{$res_url}>/js/wap/jquery.min.js"></script>
<!------购物车加减数量------->
<script type="text/javascript" src="<{$res_url}>/js/wap/jquery.Spinner.js"></script>

<!-------弹窗------->
<script type="text/javascript" src="<{$res_url}>/js/wap/layer.m.js"></script>

</head>

<body style="background:#f8f9fa;">
	
    <section class="warp" style="padding-bottom:14px;">
    	<div class="content">
<!--            <header>
                <div class="logo">购物车</div>
            </header>-->
            <form action="amember-checkout.html" method="post">
            <section class="car_home">
                <{if $cart.list_group_by_tip}><{foreach from=$cart.list_group_by_tip item=tip}>
                <{if($tip.goods)}>
            	<div class="car_item" id='item_<{$tip.tip_id}>'>
                	<div class="car_item_tit" data-tip="<{$tip.tip_id}>"><{$tip.tip_name}></div>
                        
                        <{foreach from=$tip.goods item=goods}>
                        <{foreach from=$goods.obj_items.products item=product}>
                        <dl data-productid="<{$product.product_id}>">
                                <dt class="left">
                                    <label class="chose">
                                        <div class="checkboxFour">
                                            <input type="checkbox" value="<{$goods.obj_ident}>" id="cart_<{$tip.tip_id}>_<{$product.product_id}>" checked name="obj_ident[<{$tip.tip_id}>][]"/>
                                            <ins for="cart_<{$tip.tip_id}>_<{$product.product_id}>"></ins>
                                        </div>
                                    </label>
                                </dt>
                                <dt class="img"><img src="<{$product.thumbnail_url}>" width="50" height="50"></dt>
                                <dt class="right">
                                <p>￥<font class="price_<{$tip.tip_id}>_<{$product.product_id}>"></font></p>
                                    <a href="javascript:;" class="del">删 除</a>
                                </dt>
                                <dd>
                                    <h2><{$product.name|cut:30}></h2>
                                    <div class="Spinner Spinner_<{$tip.tip_id}>_<{$product.product_id}>" data-price="<{$product.price.price}>"></div>
                                </dd>
                                
                                <script type="text/javascript">
                                        $(function(){
                                                
                                                $(".Spinner_<{$tip.tip_id}>_<{$product.product_id}>").Spinner({value:<{$goods.quantity}>, min:1, len:3, max:100});
                                                getamount(<{$tip.tip_id}>,<{$product.product_id}>);
                                        });
                                </script>
                            </dl>
                        <{/foreach}>
                        <{/foreach}>
                       
                    <div class="car_home_bottom">
                        <label class="chose">
                            <div class="checkboxFour">
                                <input type="checkbox" value="" id="checkboxFourInput" name="" checked class="all" />
                                <ins for="checkboxFourInput"></ins>
                            </div>
                            <span>全选</span>
                        </label>
                        <b>合计：￥<font id="amount_<{$tip.tip_id}>"></font></b>
                        <a href="javascript:;" onclick='submit_that(<{$tip.tip_id}>)' class="pay_btn">支付</a>
                    </div>
                </div>
                <{/if}>
                
                <{/foreach}>
                <{else}>
                您的购物车没有任何商品
                <{/if}>
                <input type="hidden" name='tip' id='tip' >
                <script type="text/javascript">
					$(function(){
							$(".car_home_bottom input.all").click(function(){
									if(this.checked){
										$(this).parentsUntil(".car_home").find("dt.left input[type=checkbox]").attr("checked", true);
									}else{
										$(this).parentsUntil(".car_home").find("dt.left input[type=checkbox]").attr("checked", false);
									}  
							});
						})
                                                function submit_that(tip){
                                                    var str;
                                                    $(" input[name='obj_ident["+tip+"][]']").each(function(index,item){
                                                        if($(item).val()){
                                                            str = str+","+$(item).val()
                                                        }
                                                    });
                                                    $("#tip").val(str);
                                                    $('form').submit();
                                                }
				</script>
                <script type="text/javascript">
					$(function(){
							$(".car_home dl dt.right a.del").click(function(){
									layer.open({
										content: '确定删除此商品？',
										btn: ['确认', '取消'],
										shadeClose: false,
										yes: function(index){
											location.reload();
											layer.close(index);
										}
									});
								})
						})
                </script>
                
                <script type="text/javascript">
					function getamount(){
                                            $(".car_item ").each(function(index,obj){
                                                var amount = 0;
                                                tip = $(obj).find(".car_item_tit").attr("data-tip");
                                                $(obj).find('dl').each(function(index,item){
                                                    product_id = $(item).attr("data-productid");
                                                    var price = $(".Spinner_"+tip+"_"+product_id+" input").val()*$(".Spinner_"+tip+"_"+product_id+"").attr("data-price");
                                                    $(".price_"+tip+"_"+product_id).html(price.toFixed(2));
                                                    amount = Number(amount)+Number(price.toFixed(2));
                                                })
                                                
                                                $("#amount_"+tip).html(amount.toFixed(2));
                                            })
                                            
                                        }
				</script>
            </section>
                </form>
           <{wap_require file="block/member-footer.html"}> 
            
        </div>
    </section>
